@page
@model B.WMS.Web.Pages.Inventory.IndexModel
@{
    ViewData["Title"] = "盘点管理";
}

<div class="container-fluid">
    <!-- 搜索区域 -->
    <div class="card mb-3">
        <div class="card-header">
            <h5 class="mb-0">搜索条件</h5>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-3">
                    <div class="form-group">
                        <label for="reviewNo">盘点单号</label>
                        <input type="text" class="form-control" id="reviewNo" placeholder="请输入">
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="form-group">
                        <label for="reviewResult">盘点结果</label>
                        <select class="form-control" id="reviewResult">
                            <option value="">请选择</option>
                            <option value="1">草稿</option>
                            <option value="2">有盈亏</option>
                            <option value="3">无盈亏</option>
                        </select>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="form-group">
                        <label for="reviewType">盘点类型</label>
                        <select class="form-control" id="reviewType">
                            <option value="">请选择</option>
                            <option value="存货盘点">存货盘点</option>
                            <option value="循环盘点">循环盘点</option>
                        </select>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="form-group">
                        <label for="warehouseName">仓库名称</label>
                        <select class="form-control" id="warehouseName">
                            <option value="">请选择</option>
                            <option value="货品仓库一">货品仓库一</option>
                            <option value="货品仓库二">货品仓库二</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="row mt-3">
                <div class="col-md-12">
                    <button type="button" class="btn btn-secondary" onclick="resetSearch()">重置</button>
                    <button type="button" class="btn btn-success" onclick="searchInventory()">查询</button>
                    <button type="button" class="btn btn-info" onclick="showAdvancedSearch()">高级搜索</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 操作按钮区域 -->
    <div class="card mb-3">
        <div class="card-body">
            <button type="button" class="btn btn-success" onclick="addInventory()">
                <i class="fas fa-plus"></i> 新增
            </button>
            <button type="button" class="btn btn-danger" onclick="deleteSelected()">
                <i class="fas fa-trash"></i> 删除
            </button>
            <button type="button" class="btn btn-warning" onclick="exportData()">
                <i class="fas fa-download"></i> 导出
            </button>
            <button type="button" class="btn btn-secondary" onclick="invalidateSelected()">
                <i class="fas fa-ban"></i> 作废
            </button>
            <button type="button" class="btn btn-info" onclick="lockWarehouse()">
                <i class="fas fa-lock"></i> 锁定仓库
            </button>
            <button type="button" class="btn btn-primary" onclick="refreshData()">
                <i class="fas fa-sync"></i> 刷新
            </button>
        </div>
    </div>

    <!-- 数据表格区域 -->
    <div class="card">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-striped table-hover" id="inventoryTable">
                    <thead>
                        <tr>
                            <th>
                                <input type="checkbox" id="selectAll" onchange="toggleSelectAll()">
                            </th>
                            <th>序号</th>
                            <th>盘点单号</th>
                            <th>盘点结果</th>
                            <th>仓库名称</th>
                            <th>盘点类型</th>
                            <th>盘点开始时间</th>
                            <th>盘点结束时间</th>
                            <th>出库状态</th>
                            <th>入库状态</th>
                            <th>盘点货品</th>
                            <th>盘点数量</th>
                            <th>盘盈数量</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody id="inventoryTableBody">
                        <!-- 数据将通过JavaScript动态加载 -->
                    </tbody>
                </table>
            </div>

            <!-- 分页区域 -->
            <div class="d-flex justify-content-between align-items-center mt-3">
                <div>
                    总 <span id="totalCount">0</span> 条
                </div>
                <div class="d-flex align-items-center">
                    <button class="btn btn-sm btn-outline-primary" onclick="previousPage()">&lt;</button>
                    <div class="mx-2" id="pageNumbers">
                        <!-- 页码将通过JavaScript动态生成 -->
                    </div>
                    <button class="btn btn-sm btn-outline-primary" onclick="nextPage()">&gt;</button>
                    <select class="form-control form-control-sm ml-2" id="pageSize" onchange="changePageSize()">
                        <option value="10">10条/页</option>
                        <option value="20">20条/页</option>
                        <option value="50">50条/页</option>
                    </select>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 新增/编辑盘点模态框 -->
<div class="modal fade" id="inventoryModal" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="modalTitle">新增盘点</h5>
                <button type="button" class="close" data-dismiss="modal">
                    <span>&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form id="inventoryForm">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>盘点单号</label>
                                <input type="text" class="form-control" id="modalReviewNo" readonly>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>盘点类型 <span class="text-danger">*</span></label>
                                <select class="form-control" id="modalReviewType" required>
                                    <option value="">请选择</option>
                                    <option value="存货盘点">存货盘点</option>
                                    <option value="循环盘点">循环盘点</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>盘点开始时间 <span class="text-danger">*</span></label>
                                <input type="datetime-local" class="form-control" id="modalStartTime" required>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>盘点结束时间 <span class="text-danger">*</span></label>
                                <input type="datetime-local" class="form-control" id="modalEndTime" required>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>仓库名称 <span class="text-danger">*</span></label>
                                <div class="input-group">
                                    <select class="form-control" id="modalWarehouseName" required>
                                        <option value="">请选择</option>
                                        <option value="货品仓库一">货品仓库一</option>
                                        <option value="货品仓库二">货品仓库二</option>
                                    </select>
                                    <div class="input-group-append">
                                        <button type="button" class="btn btn-outline-secondary" onclick="openWarehouseSettings()">设置</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>经办人 <span class="text-danger">*</span></label>
                                <div class="input-group">
                                    <select class="form-control" id="modalUserId" required>
                                        <option value="">请选择</option>
                                    </select>
                                    <div class="input-group-append">
                                        <button type="button" class="btn btn-outline-secondary" onclick="selectUser()">...</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>备注</label>
                        <textarea class="form-control" id="modalRemark" rows="3" placeholder="请输入"></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="saveInventory()">保存</button>
            </div>
        </div>
    </div>
</div>

@section Scripts {
    <script src="~/Pages/Inventory/Index.js"></script>
} 